package io.renren.modules.app.entity;

import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.renren.common.validator.group.AddCarInfo;
import org.apache.commons.lang.StringUtils;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * @Auther zxl
 * @Date 2018/12/15 19:18
 * @Description
 **/
@TableName("app_u_car")
public class UserCarEntity implements Serializable {

    /**
     * 自增id
     */
    @TableId(value = "id",type = IdType.AUTO)
    private Integer id;

    /**
     * 用户id
     */
    @TableId(value = "user_id")
    private Long userId;

    /**
     * 是否为运营车
     * 1：运营车
     * 0: 非运营车
     */
//    @NotNull(message = "信息不完整，需告知是否为运营车",groups = {AddCarInfo.class})
    @TableId(value = "operate_car")
    private Integer operateCar;

    /**
     * 车辆类型
     * 5：5座；7：7座；
     */
    @NotNull(message = "信息不完整，车辆类型不能为空",groups = {AddCarInfo.class})
    @TableId(value = "car_type")
    private Integer carType;

    /**
     * 车牌号
     */
    @NotBlank(message = "信息不完整，车牌号不能为空",groups = {AddCarInfo.class})
    @TableId(value = "plate_num")
    private String plateNum;

    /**
     * 车辆识别代号
     */
    @TableId(value = "vin")
    @Length(max = 17,min = 17,message = "车辆识别代号是17位",groups = {AddCarInfo.class})
    private String vin;

    /**
     * 车辆类型
     */
    @TableId(value = "vehicle_type")
    private String vehicleType;

    /**
     * 所有人名称
     */
    private String owner;

    /**
     * 使用性质
     */
    @TableId(value = "use_character")
    private String useCharacter;

    /**
     * 地址
     */
    private String addr;

    /**
     * 品牌型号
     */
    private String model;

    /**
     * 发动机号码
     */
    @TableId(value = "engine_num")
    private String engineNum;

    /**
     * 注册时间
     */
    @NotNull(message = "信息不完整，车辆注册时间能为空",groups = {AddCarInfo.class})
    @TableId(value = "register_date")
    @JsonFormat(pattern="yyyy-MM-dd")
    private Date registerDate;

    /**
     * 发证日期
     */
    @TableId(value = "issue_date")
    @JsonFormat(pattern="yyyy-MM-dd")
    private Date issueDate;


    /**
     * 创建时间
     */
    @TableId(value = "create_time")
    private Date createTime;

    public UserCarEntity() {
    }

    public UserCarEntity(VehicleEntity entity) {
        this.userId=entity.getUserId();
        this.plateNum=entity.getPlate_num();
        this.vin=entity.getVin();
        this.vehicleType=entity.getVehicle_type();
        this.engineNum=entity.getEngine_num();
        this.owner=entity.getOwner();
        this.model=entity.getModel();
        this.addr=entity.getAddr();
        this.registerDate=entity.getRegister_date();
        this.issueDate=entity.getIssue_date();
        this.useCharacter=entity.getUse_character();
        this.operateCar = StringUtils.equals(entity.getUse_character(),"运营车") ? 1 : 0;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public Integer getOperateCar() {
        return operateCar;
    }

    public void setOperateCar(Integer operateCar) {
        this.operateCar = operateCar;
    }

    public Integer getCarType() {
        return carType;
    }

    public void setCarType(Integer carType) {
        this.carType = carType;
    }

    public String getPlateNum() {
        return plateNum;
    }

    public void setPlateNum(String plateNum) {
        this.plateNum = plateNum;
    }

    public String getVin() {
        return vin;
    }

    public void setVin(String vin) {
        this.vin = vin;
    }

    public String getVehicleType() {
        return vehicleType;
    }

    public void setVehicleType(String vehicleType) {
        this.vehicleType = vehicleType;
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        this.owner = owner;
    }

    public String getUseCharacter() {
        return useCharacter;
    }

    public void setUseCharacter(String useCharacter) {
        this.useCharacter = useCharacter;
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getEngineNum() {
        return engineNum;
    }

    public void setEngineNum(String engineNum) {
        this.engineNum = engineNum;
    }

    public Date getRegisterDate() {
        return registerDate;
    }

    public void setRegisterDate(Date registerDate) {
        this.registerDate = registerDate;
    }

    public Date getIssueDate() {
        return issueDate;
    }

    public void setIssueDate(Date issueDate) {
        this.issueDate = issueDate;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "UserCarEntity{" +
                "id=" + id +
                ", userId=" + userId +
                ", operateCar=" + operateCar +
                ", carType=" + carType +
                ", plateNum='" + plateNum + '\'' +
                ", vin='" + vin + '\'' +
                ", vehicleType='" + vehicleType + '\'' +
                ", owner='" + owner + '\'' +
                ", useCharacter='" + useCharacter + '\'' +
                ", addr='" + addr + '\'' +
                ", model='" + model + '\'' +
                ", engineNum='" + engineNum + '\'' +
                ", registerDate=" + registerDate +
                ", issueDate=" + issueDate +
                ", createTime=" + createTime +
                '}';
    }
}
